<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
    File: Flash_helper.php

    This helper provides a function to save a flash message to a cookie,
    retrieve it on next page load and remove the cookie.
    
    Usage:
        A flash can be set once the flash helper is loaded with
        > flash('hello world');
        
        and retrieved on the next page load by
        > $ci_instance->flash;
*/


/*
    Function: flash
    Save cookie containing cleaned string
    
    Arguments:
        input   - The string to store as flash
*/
function flash($input) {
    set_cookie('flash', $input, 0);
}

/*
    Function: clear_flash
    Delete the cookie
*/
function clear_flash() {
    delete_cookie('flash');
}

/*
    Function: init_flash
    Retrive the flash cookie, assign it to the ci instance and clear the flash
*/
function init_flash() {
    get_instance()->flash = get_cookie('flash', true);
    clear_flash();
}

?>